package com.example.javasample.controller;

import com.example.javasample.domain.Origin;
import com.example.javasample.service.IOriginService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * OriginController
 *
 * @author Kylin
 */
@ApiSupport(order = 1)
@Tag(name = "原初对象")
@RestController
@RequestMapping("/origin")
public class OriginController {

    @Autowired
    private IOriginService originService;

    @ApiOperationSupport(order = 1)
    @Operation(summary = "列表", description = "")
    @GetMapping(value = "/list")
    public List<Origin> list(@ParameterObject Origin origin) {
        return originService.list(origin);
    }

    @ApiOperationSupport(order = 2)
    @Operation(summary = "新增", description = "")
    @PostMapping("/add")
    public int add(@ParameterObject Origin origin) {
        return originService.add(origin);
    }

    @ApiOperationSupport(order = 3)
    @Operation(summary = "批量新增", description = "")
    @PostMapping("/batchAdd")
    public int batchAdd(@RequestBody List<Origin> originList) {
        return originService.batchAdd(originList);
    }

    @ApiOperationSupport(order = 4)
    @Operation(summary = "编辑", description = "")
    @PutMapping("/edit")
    public boolean edit(@ParameterObject Origin origin) {
        return originService.edit(origin);
    }

    @ApiOperationSupport(order = 5)
    @Operation(summary = "详情", description = "")
    @GetMapping("/detail/{originId}")
    public Origin detail(@PathVariable Long originId) {
        return originService.detail(originId);
    }

    @ApiOperationSupport(order = 6)
    @Operation(summary = "删除", description = "")
    @DeleteMapping("/delete/{originId}")
    public int delete(@PathVariable Long originId) {
        return originService.delete(originId);
    }

    @ApiOperationSupport(order = 7)
    @Operation(summary = "物理删除", description = "")
    @DeleteMapping("/physicallyDelete/{originId}")
    public int physicallyDelete(@PathVariable Long originId) {
        return originService.physicallyDelete(originId);
    }

}
